home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 045a / btp15.zip / CREATE1.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-09  |  2KB  |  63 lines

  1. PROGRAM Create1;             { (C) 1991 John C. Leon    last updated 11/9/91 }
  2.  
  3. {
  4. Creates an empty Btrieve file of record length 30 with 2 keys.  This empty
  5. file is used in EXAMPLE1.PAS, and should be named EXAMPLE (no extension).
  6. }
  7.  
  8. {$IFDEF production} {$D-,R-,L-,S-} {$ENDIF}
  9.  
  10. USES
  11.    BTP;
  12.  
  13. VAR
  14.    Counter,
  15.    Counter1   : integer;
  16.    MyFileSpec : PFileSpec;
  17.    MyFileName : string;
  18.  
  19. BEGIN
  20.   MyFileSpec := new(PFileSpec);
  21.   with MyFileSpec^ do
  22.     begin
  23.       {Create a fixed length, standard Btrieve file, with no pre-allocation  }
  24.       {and no alternate collating sequence.                                  }
  25.       RecLen   :=   30;   FileFlags := 0;
  26.       PageSize :=  512;   PreAlloc  := 0;
  27.       NumKeys  :=    2;
  28.       fillchar(KeyArray, sizeof(KeyArray), 0);       {This line is MANDATORY!}
  29.       {Key #0}
  30.       with KeyArray[0] do
  31.          begin
  32.          KeyPos := 11; KeyLen := 20;
  33.          {recommend ALWAYS using ExtType in KeyFlags assignment}
  34.          KeyFlags := Duplicates + Modifiable + ExtType;
  35.          {Note that if KeyFlags includes Binary, the Binary flag bit will
  36.           override any ExtKeyType you may set...and the key will be treated
  37.           as an unsigned binary!!}
  38.          ExtKeyType:= BString; {always assign a value to this element}
  39.          end;
  40.       {Key #1}
  41.       with KeyArray[1] do
  42.          begin
  43.          KeyPos :=  1; KeyLen := 10;
  44.          KeyFlags := Duplicates + Modifiable + ExtKeyType;
  45.          ExtKeyType := BString;
  46.          end;
  47.     end; {with MyFileSpec^ do}
  48.  
  49.   write('Enter name of file to create: ');
  50.   readln(MyFileName);
  51.   BStatus := CreateFile(MyFileName, MyFileSpec, ''); {'' = no alt col seq}
  52.   dispose(MyFileSpec);
  53.   if BStatus <> 0 then
  54.     writeln('Error creating file.  Status = ', BStatus)
  55.     else
  56.     begin
  57.     for Counter := 1 to length(MyFileName) do
  58.        MyFileName[Counter] := upcase(MyFileName[Counter]);
  59.     writeln('File ', MyFileName, ' created successfully.');
  60.     end;
  61.  
  62. END.
  63.